package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import pojo.Info;
import pojo.Dictionary;
import service.AppInfoService;
import service.DataDictionaryService;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping(value ="/zs/")
public class AppInfoContronller {
    @Resource
    private AppInfoService appInfoService;
    @Resource
    private DataDictionaryService dataDictionaryService;
    @RequestMapping("appInfo")
    public String getAppInfo(){
        return "developer/appinfoadd";
    }

    @RequestMapping(value ="apkexisits",method = RequestMethod.POST)
    @ResponseBody
    public String apkexisist(String APKName){
        List<Info> appInfos=appInfoService.findAPPInfo(APKName);
        if(null==APKName || APKName.equals("")){
            return "{\"APKName\":\"K\"}";
        }else{
            if(appInfos.size()==0 || appInfos==null){//APKName未被使用
                return "{\"APKName\":\"T\"}";
            }else{//已被使用
                return "{\"APKName\":\"F\"}";
            }
        }
    }

    @RequestMapping(value ="pingTai")
    @ResponseBody
    public String getPingTai(){//加载所属平台
        List<Dictionary> dataDictionaryList=dataDictionaryService.findDataDiction();
        return  "{\"dataDictionaryList\":"+dataDictionaryList+"}";
    }
}
